<template>
	<view>
		<swiper class="margin-top-lg" style="height: 300rpx;" :circular="true" :duration="500" @change="swChange" :current="init">
			<swiper-item v-for="i in level" :key="i.id" :item-id="i.id.toString()">
				<view class="swiper-item" :style="'background-image: url(../../static/images/lv'+i.id+'.png);background-size: 100% 100%;'">
					<view class="main padding-lr-lg padding-top-xl flex-col justify-start">
						<view class="tag" v-if="i.id==myLevel.id"></view>
						<view class="padding-top">
							<view class="margin-top-xl">直推设计绩效比例一级（实付金额）{{i.design_l1}}%</view>
							<view>物料绩效（实付金额）{{i.material}}%</view>
							<u-line-progress style="margin: 8rpx 0;" :percent="percent" active-color="#fff" inactive-color="#E8D8D9" :show-percent="false" height="6" v-if="i.id==myLevel.id"></u-line-progress>
							<view v-if="i.id==myLevel.id">当前积分{{score}}/{{myLevel.score_max}}</view>
						</view>
					</view>
				</view>
			</swiper-item>
		</swiper>

		<view class="info padding-tb padding-lr-lg">
			<view class="title">
				会员定义
			</view>
			<view class="content">
				{{active.score_min?`${active.score_min}积分＜`:''}}积分信誉累积{{active.score_max?`≤${active.score_max}积分`:''}}
			</view>
			<view class="title">
				会员权益
			</view>
			<view class="content">
				直推设计绩效比例一级（实付金额）{{active.design_l1}}%
			</view>
			<view class="content">
				物料绩效（实付金额）{{active.material}}%
			</view>
			<view class="content">
				排队特权：优先处理
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				init: '',
				score: '',
				percent: '',
				level: '',
				myLevel: '',
				active: ''
			};
		},
		onLoad() {
			this.getLevel();
		},
		methods: {
			getLevel() {
				this.$u.get('/level/privilege').then(res => {
					let result = res.data.result
					this.level = result.level_list
					this.myLevel = result.level
					this.cgLevel(this.myLevel.id)
					this.init = this.myLevel.id - 1
					let score = result.score
					this.score = score
					this.percent = score / this.myLevel.score_max * 100
				})
			},
			swChange(e) {
				let id = e.detail.currentItemId
				this.cgLevel(id);
			},
			cgLevel(id) {
				let item = this.level.find(item => item.id == id)
				this.active = item
			}
		}
	}
</script>

<style lang="scss">
	uni-swiper-item {
		width: 690rpx !important;
		height: 300rpx !important;
		left: 40rpx;
	}
	.swiper-item {
		width: 670rpx;
		height: 300rpx;
		position: relative;
	
		.main {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			line-height: 34rpx;
		}
		.tag {
			width: 180rpx;
			height: 56rpx;
			background-image: url(../../static/images/lv0.png);
			background-size: 100% 100%;
			position: absolute;
			top: 25%;
			right: 0;
			transform: translateY(-50%);
		}
	}

	.info {
		width: 670rpx;
		background: rgba(255, 255, 255, 1);
		margin: 0 auto;
		margin-top: 56rpx;
		border-radius: 8rpx;

		.title {
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #444444;
			line-height: 44rpx;
			margin-top: 32rpx;
			margin-bottom: 16rpx;
			position: relative;

			&:nth-of-type(1) {
				margin-top: 0;
			}

			&::before {
				content: '';
				width: 8rpx;
				height: 32rpx;
				background: rgba(233, 193, 129, 1);
				position: absolute;
				top: 50%;
				left: 0;
				transform: translate(-300%, -50%);
			}
		}

		.content {
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 40rpx;
		}
	}
</style>
